<!DOCTYPE HTML>
<html  lang="zh" xmlns:th="http://www.thymeleaf.org">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<link th:href="@{/ajax/libs/summernote/summernote.css}" rel="stylesheet"/>
<link th:href="@{/ajax/libs/summernote/summernote-bs3.css}" rel="stylesheet"/>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-jobgroup-add">
			<div class="form-group">	
				<label class="col-sm-3 control-label">AppName：</label>
				<div class="col-sm-8">
					<input id="appName" name="appName" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">名称：</label>
				<div class="col-sm-8">
				    <input id="title" name="title" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">排序：</label>
				<div class="col-sm-8">
				    <input id="order" name="order" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">项目：</label>
				<div class="col-sm-8">
				   <select class="form-control" id="projectId" name="projectId"  th:with="type=${@project.getProject()}">
					    <option th:each="project : ${type}" th:text="${project.projectName}" th:value="${project.projectId}"></option>
				   </select>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">注册方式：</label>
				<div class="col-sm-8">
					<div class="radio-box">
					<input type="radio"  name="addressType" id="addressType1"  value="0" checked><label th:for="addressType1" th:text="自动注册"></label>
					</div>
					<div class="radio-box">
					<input type="radio"  name="addressType" id="addressType2" value="1"> <label th:for="addressType2" th:text="手动录入"></label>
					</div>
				</div>
			</div>
            <div class="form-group">
				<label class="col-sm-3 control-label">机器地址：</label>
				<div class="col-sm-8">
					<textarea id="addressList" name="addressList" class="form-control" placeholder="请输入执行器地址列表，多地址逗号分隔">[[*{addressList}]]</textarea>
				</div>
			</div>
		</form>
	</div>
    <div th:include="include::footer"></div>
    <script type="text/javascript">
        var prefix = ctx + "job/jobgroup";
        
		jQuery.validator.addMethod("myValid01", function(value, element) {
			var length = value.length;
			var valid = /^[a-z][a-zA-Z0-9-]*$/;
			return this.optional(element) || valid.test(value);
		}, '限制以小写字母开头，由小写字母、数字和中划线组成');
		$("#form-jobgroup-add").validate({
			rules:{
				appName:{
					required:true,
					rangelength:[4,64],
					myValid01 : true
				},
				title : {
					required : true,
					rangelength:[4, 12]
				},
				order : {
					required : true,
					digits:true,
					range:[1,1000]
				}
			},
			messages : {
				appName : {
					required : '请输入'+"AppName",
					rangelength: 'AppName长度限制为4~64' ,
					myValid01: '限制以小写字母开头，由小写字母、数字和中划线组成'
				},
				title : {
					required : '请输入' + '名称' ,
					rangelength: '名称长度限制为4~12'
				},
				order : {
					required : '请输入排序' ,
					digits: '请输入整数' ,
					range: '取值范围为1~1000'
				}
			}
		});
		
		function submitHandler() {
	        if ($.validate.form()) {
				$.operate.save(prefix + "/add", $('#form-jobgroup-add').serialize());
	        }
	    }		
	</script>
</body>
</html>
